<?php defined('SYSPATH') or die('No direct script access.');

// URL: /<context>/index.php/Home/
class Controller_Test extends Controller_Base 
{
	protected $postService;
	
	public function __construct(Request $request, Response $response)
	{
		parent::__construct($request, $response);
		$this->postService = new Service_PostServiceStub('http://localhost:8080/seednia-webapp/ws/PostServiceRest/');
		$this->postService->setAccessToken('seedniaPhpUi');
		$this->postService->init($this->_sessionInfo);
	}
	
	/*
	public function before()
	{
		parent::before();
	}
	
	public function after()
	{
		parent::after();
	}*/
	
	public function action_show_post_form()
	{
		$this->template->title = __('Welcome Seednia');
		$this->template->scripts = array('public/js/home.js');
		
		$content = View::factory('default/test_post');
		
		try {

			$content->posts = $this->postService->getList(null, 0, 10);
	
			//echo Debug::vars($content->posts);
			
			$this->template->content = $content;
		} catch (Exception $ex)
		{
			Kohana_Log::instance()->add(Kohana_Log::ERROR, 'Exception::Add Lis | Message: ' . $ex->getMessage());
		}
	}
	
} // End Controller_Home